//
//  BKLHealth_MCFamousDoctorController.m
//  BKLMedicalCare
//
//  Created by ma c on 2017/6/14.
//  Copyright © 2017年 q mac. All rights reserved.
//

#import "BKLHealth_MCFamousDoctorController.h"
#import "BKL_CycelScrollView.h"
#import "UIViewController+BKLHTable.h"
#import <Masonry.h>
@interface BKLHealth_MCFamousDoctorController () <BKLHealth_MCFDDepartmentCellDelegate>
@property (nonatomic, weak) BKL_CycelScrollView *cycelView;
@property (nonatomic, weak) UITableView *tableView;
@end

@implementation BKLHealth_MCFamousDoctorController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.sectionArray = [self dataSource];
    [self initializeComponents];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

- (void)initializeComponents {
    
    BKL_CycelScrollView *cycelView = [[BKL_CycelScrollView alloc] initWithFrame:CGRectMake(0, 0, 0, 164)];
    cycelView.images = [self testCycelImages];
    _cycelView = cycelView;
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    tableView.backgroundColor = [UIColor clearColor];
    tableView.showsVerticalScrollIndicator = NO;
    tableView.tableHeaderView = _cycelView;
    tableView.delegate = self;
    tableView.dataSource = self;
    _tableView = tableView;
    [self.view addSubview:_tableView];
    
    [self makeConstraints];
}


- (NSArray *)testCycelImages {
    return @[@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497519649638&di=3a994a1097b4eacb43c484990e8dd7fe&imgtype=0&src=http%3A%2F%2Fpic.90sjimg.com%2Fback_pic%2F00%2F00%2F52%2F00%2F444e0feebdb0040ff0f020c6a0954eb4.jpg",
             @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497519677034&di=77aabbd28b114cfdbd13e3c19871e05d&imgtype=0&src=http%3A%2F%2Fpic.90sjimg.com%2Fback_pic%2Fqk%2Fback_origin_pic%2F00%2F02%2F79%2F9a31517294c24da497fb84251735c447.jpg",
             @"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1066462716,4040550561&fm=26&gp=0.jpg",
             @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497521109341&di=115c193ed75314e69c4514a3c69774a8&imgtype=0&src=http%3A%2F%2Fpic.58pic.com%2F58pic%2F17%2F23%2F86%2F52y58PICmMS_1024.jpg"
             ];
}

- (void)makeConstraints {
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

- (NSArray <BKLHealth_MCSectionModel *> *)dataSource {
    
    NSMutableArray *s0c0Arr = [NSMutableArray array];
    for (int i = 0; i < 2; i++) {
        NSMutableArray *marr = [NSMutableArray array];
        for (int i = 0; i < 8; i++) {
            NSDictionary *dic = @{@"imageString" : @"产科", @"content" : @"产科"};
            [marr addObject:dic];
        }
        [s0c0Arr addObject:marr.copy];
    }
    
    BKLHealth_MCCellModel *s0c0 = [[BKLHealth_MCCellModel alloc] init];
    s0c0.className = NSStringFromClass([BKLHealth_MCFDDepartmentCell class]);
    s0c0.delegate = self;
    s0c0.identifier = @"bkl_departmentCellIdentifier";
    s0c0.heignt = [BKLHealth_MCFDDepartmentCell computeHeight:s0c0Arr.copy];
    s0c0.data = s0c0Arr.copy;
    
    BKLHealth_MCSectionModel *s0 = [[BKLHealth_MCSectionModel alloc] init];
    s0.headerClassName = NSStringFromClass([BKLHealth_MCFDTitleHeaderView class]);
    s0.headerIdentifier = @"bkl_titleHeaderViewIdentifier";
    s0.headerHeight = [BKLHealth_MCFDTitleHeaderView computeHeight:@[]];
    s0.footerHeight = 8;
    s0.headerData = @{@"title" : @"按科室找医生"};
    s0.cellModels = @[s0c0];
    
    return @[s0];
}


//
- (void)departmentCell:(BKLHealth_MCFDDepartmentCell *)cell didSelectedItem:(NSIndexPath *)indexPath {
    NSLog(@"%@", indexPath);
}

@end
